import router, { routes } from './router'


const setPageConfig = (item:any)=>{
	let body ={
		wtg:'1',
		applet:"1",
		title:item.meta.title?item.meta.title :' ',
		hasBack:item.meta.hasBack,
		hasLogo:item.meta.hasLogo,
		logo:{
			width:150,
			height:48,
			pic:"http://emoji.mpshenghuo.com/wtgLogo.png",
		}
	}
	if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
		window.webkit.messageHandlers.setNavData.postMessage(
		  JSON.stringify(body)
		); //调用ios方法
	  } else if (/(Android)/i.test(navigator.userAgent)) {
		window.myjs.setNavData(body.wtg,body.applet,body.title,body.hasBack,body.hasLogo,JSON.stringify(body.logo)); //myjs 是android端和js协商定义的调用对象, 是方法名,
	  }
}



//全局守卫路由
router.beforeEach(async (to, from, next) => {
	setPageConfig(to)
	next()
})
